package com.secret.chain.secretchain.controller.wx;

import com.secret.chain.secretchain.domain.entity.Comment;
import com.secret.chain.secretchain.result.Result;
import com.secret.chain.secretchain.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wx/comment")
@CrossOrigin
public class CommentsController {
    @Autowired
    private CommentService commentsService;

    @GetMapping("{articleId}")
    public Result<Comment> queryByArticleId(@PathVariable Integer id){
        Result<Comment> result =commentsService.queryByArticleId(id);
        return result;
    }

    @GetMapping("{userId}")
    public Result<Comment> queryByUserId(@PathVariable Integer id){
        Result<Comment> result =commentsService.queryByUserId(id);
        return result;
    }

    @PostMapping
    public Result<Void> save(@RequestBody Comment comment){
        return commentsService.save(comment);
    }
    @DeleteMapping
    public Result<Void> delete(Integer id){
        return commentsService.delete(id);
    }
    @PutMapping
    public Result<Void> update(@RequestBody Comment comment){
        return commentsService.update(comment);
    }


}
